# Copyright 2024 Ant Group Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@yacl//bazel:yacl.bzl", "yacl_cc_binary", "yacl_cc_library", "yacl_cc_test")

package(default_visibility = ["//visibility:public"])

yacl_cc_library(
    name = "paillier_ipcl",
    hdrs = ["ipcl.h"],
    deps = select({
        "@platforms//cpu:x86_64": [
            ":paillier_ipcl_impl",
        ],
        "//conditions:default": [],
    }),
)

yacl_cc_library(
    name = "paillier_ipcl_impl",
    srcs = [
        "ciphertext.cc",
        "key_generator.cc",
        "plaintext.cc",
        "public_key.cc",
        "secret_key.cc",
        "utils.cc",
        "vector_decryptor.cc",
        "vector_encryptor.cc",
        "vector_evaluator.cc",
    ],
    hdrs = [
        "ciphertext.h",
        "key_generator.h",
        "plaintext.h",
        "public_key.h",
        "secret_key.h",
        "utils.h",
        "vector_decryptor.h",
        "vector_encryptor.h",
        "vector_evaluator.h",
    ],
    target_compatible_with = [
        "@platforms//cpu:x86_64",
    ],
    deps = [
        "//heu/library/algorithms/util",
        "@com_github_fmtlib_fmt//:fmtlib",
        "@com_github_intel_ipcl//:ipcl",
        "@com_github_msgpack_msgpack//:msgpack",
        "@com_github_uscilab_cereal//:cereal",
        "@yacl//yacl/base:byte_container_view",
        "@yacl//yacl/base:int128",
    ],
)

yacl_cc_test(
    name = "ipcl_test",
    srcs = ["ipcl_test.cc"],
    target_compatible_with = [
        "@platforms//cpu:x86_64",
    ],
    deps = [
        ":paillier_ipcl",
    ],
)
